function mb = report_state(varargin)
    msg = varargin{1};
    if nargin == 1
        mb = msgbox(['Sorry, there''s been an error; here''s the error message: ' msg]);
    elseif strcmp(varargin{2}, 'DB')
        mb = msgbox(['Sorry, there''s been a datbase error; here''s the error message: ' msg]);
    elseif strcmp(varargin{2}, 'modal')
        mb = {msgbox(msg, 'modal')};
        mb{2} = findobj('Style', 'pushbutton');
        set(mb{2}, 'Enable', 'off')
        mb{3} = findobj('Tag', 'MessageBox');
    elseif strcmp(varargin{2}, 'Q')
      % varargin{3} is the dialog title; varargin{4} is a cell array of
      % up to three button labels, of which mb will contain tht chosen one
        mb = questdlg(msg, varargin{3}, varargin{4}{1}, varargin{4}{2}, varargin{4}{1}); 
    else
        mb = msgbox(msg);
    end
end

